package com.imooc.imoocbilibili.controller;

import java.util.Arrays;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.imooc.imoocbilibili.entity.VideoComment;
import com.imooc.imoocbilibili.service.VideoCommentService;
import com.imooc.imoocbilibili.utils.R;


/**
 * 视频评论表
 *
 * @author jl
 * @since 2022-04-10 21:13:43
 */
@RestController
@RequiredArgsConstructor
public class VideoCommentController {

    private final VideoCommentService videoCommentService;

    /**
     * 添加视频评论
     */
    @PostMapping("/video-comments")
    public R addVideoComment(@RequestBody VideoComment videoComment) {
        videoCommentService.addVideoComment(videoComment);
        return R.ok();
    }

    /**
     * 分页查询视频评论
     */
    @GetMapping("/video-comments")
    public R pageListVideoComments(@RequestParam Integer pageNo, @RequestParam Integer pageSize, @RequestParam Long videoId) {
        Page<VideoComment> page = videoCommentService.queryPage(pageNo, pageSize, videoId);
        return R.ok(page);
    }


}
